import fs from 'fs'
import path from 'path'
import { axiosTsTemplate, requestTsTemplate } from './useTs'
import { axiosJsTemplate, requestJsTemplate } from './useJs'
const axiosTsFile = 'axios.ts'
const requestTsFile = 'request.ts'
const axiosJsFile = 'axios.js'
const requestJsFile = 'request.js'
export function generateTsTemplate(tsDefineDirname: string) {
  console.log(tsDefineDirname)
  const p1 = fs.promises.writeFile(path.resolve(tsDefineDirname, axiosTsFile), axiosTsTemplate())
  const p2 = fs.promises.writeFile(
    path.resolve(tsDefineDirname, requestTsFile),
    requestTsTemplate()
  )
  return Promise.all([p1, p2])
}

export function generateJsTemplate(tsDefineDirname: string) {
  const p1 = fs.promises.writeFile(path.resolve(tsDefineDirname, axiosJsFile), axiosJsTemplate())
  const p2 = fs.promises.writeFile(
    path.resolve(tsDefineDirname, requestJsFile),
    requestJsTemplate()
  )
  return Promise.all([p1, p2])
}
